]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
switcherPopup: Lookup index of items when hovering or clicking
authorJonas Dreßler <verdre@v0yd.nl>
Wed, 15 Jan 2020 15:19:41 +0000 (16:19 +0100)
committerFlorian Müllner <florian.muellner@gmail.com>
Wed, 26 Feb 2020 22:46:51 +0000 (22:46 +0000)
Right now the index that gets selected on click and motion events is set
when connecting the event inside the addItem function. If items are
added or removed (for example when an application is closed by pressing
"q"), this index isn't valid anymore and has to be updated.

To fix this, use the items themselves instead of the index as arguments
for the event handlers and lookup the index of the item inside the event
handler.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/167

js/ui/altTab.js
js/ui/switcherPopup.js

index 12b78493992128e207456a1fdc1d4b3d6b595938..35d991e20895defe3096d9bf69d893c67b7d86d1 100644 (file)
@@ -775,7 +775,9 @@ class AppSwitcher extends SwitcherPopup.SwitcherList {
 
     // We override SwitcherList's _onItemEnter method to delay
     // activation when the thumbnail list is open
-    _onItemEnter(index) {
+    _onItemEnter(item) {
+        const index = this._items.indexOf(item);
+
         if (this._mouseTimeOutId != 0)
             GLib.source_remove(this._mouseTimeOutId);
         if (this._altTabPopup.thumbnailsVisible) {
index 46a4b158adc62392d732264da672f079512b368d..f7ee2e769f9a0840653cef74afe8f3a82656494c 100644 (file)
@@ -427,9 +427,8 @@ var SwitcherList = GObject.registerClass({
         bbox.set_child(item);
         this._list.add_actor(bbox);
 
-        let n = this._items.length;
-        bbox.connect('clicked', () => this._onItemClicked(n));
-        bbox.connect('motion-event', () => this._onItemEnter(n));
+        bbox.connect('clicked', () => this._onItemClicked(bbox));
+        bbox.connect('motion-event', () => this._onItemEnter(bbox));
 
         bbox.label_actor = label;
 
@@ -452,14 +451,14 @@ var SwitcherList = GObject.registerClass({
         this._items[index].remove_accessible_state(state);
     }
 
-    _onItemClicked(index) {
-        this._itemActivated(index);
+    _onItemClicked(item) {
+        this._itemActivated(this._items.indexOf(item));
     }
 
-    _onItemEnter(index) {
+    _onItemEnter(item) {
         // Avoid reentrancy
-        if (index !== this._highlighted)
-            this._itemEntered(index);
+        if (item !== this._items[this._highlighted])
+            this._itemEntered(this._items.indexOf(item));
 
         return Clutter.EVENT_PROPAGATE;
     }